In [1]:
! pip install tensorflow


Requirement already satisfied: tensorflow in c:\users\kogentix\anaconda3\lib\site-packages (1.6.0)
Requirement already satisfied: tensorboard<1.7.0,>=1.6.0 in c:\users\kogentix\anaconda3\lib\site-packages (from tensorflow) (1.6.0)
Requirement already satisfied: grpcio>=1.8.6 in c:\users\kogentix\anaconda3\lib\site-packages (from tensorflow) (1.10.0)
Requirement already satisfied: numpy>=1.13.3 in c:\users\kogentix\anaconda3\lib\site-packages (from tensorflow) (1.15.0)
Requirement already satisfied: six>=1.10.0 in c:\users\kogentix\anaconda3\lib\site-packages (from tensorflow) (1.11.0)
Requirement already satisfied: astor>=0.6.0 in c:\users\kogentix\anaconda3\lib\site-packages (from tensorflow) (0.6.2)
Requirement already satisfied: absl-py>=0.1.6 in c:\users\kogentix\anaconda3\lib\site-packages (from tensorflow) (0.1.11)
Requirement already satisfied: termcolor>=1.1.0 in c:\users\kogentix\anaconda3\lib\site-packages (from tensorflow) (1.1.0)
Requirement already satisfied: protobuf>=3.4.0 in c:\users\kogentix\anaconda3\lib\site-packages (from tensorflow) (3.5.2)
Requirement already satisfied: gast>=0.2.0 in c:\users\kogentix\anaconda3\lib\site-packages (from tensorflow) (0.2.0)
Requirement already satisfied: wheel>=0.26 in c:\users\kogentix\anaconda3\lib\site-packages (from tensorflow) (0.30.0)
Requirement already satisfied: bleach==1.5.0 in c:\users\kogentix\anaconda3\lib\site-packages (from tensorboard<1.7.0,>=1.6.0->tensorflow) (1.5.0)
Requirement already satisfied: markdown>=2.6.8 in c:\users\kogentix\anaconda3\lib\site-packages (from tensorboard<1.7.0,>=1.6.0->tensorflow) (2.6.11)
Requirement already satisfied: html5lib==0.9999999 in c:\users\kogentix\anaconda3\lib\site-packages (from tensorboard<1.7.0,>=1.6.0->tensorflow) (0.9999999)
Requirement already satisfied: werkzeug>=0.11.10 in c:\users\kogentix\anaconda3\lib\site-packages (from tensorboard<1.7.0,>=1.6.0->tensorflow) (0.14.1)
Requirement already satisfied: setuptools in c:\users\kogentix\anaconda3\lib\site-packages (from protobuf>=3.4.0->tensorflow) (38.5.2)

In [2]:
! pip install --upgrade pip


Requirement already up-to-date: pip in c:\users\kogentix\anaconda3\lib\site-packages (18.0)

conda install numpy


In [3]:
! pip install numpy -I


Collecting numpy
  Using cached https://files.pythonhosted.org/packages/53/d1/2499797c88de95ea3239ad7f6e6a47895fe51aad1aa2a116f50ec9e0ee74/numpy-1.15.0-cp36-none-win_amd64.whl
Installing collected packages: numpy
Successfully installed numpy-1.15.0
kmodes 0.7 has requirement numpy==1.12.1, but you'll have numpy 1.15.0 which is incompatible.
kmodes 0.7 has requirement scikit-learn==0.18.1, but you'll have scikit-learn 0.19.1 which is incompatible.
kmodes 0.7 has requirement scipy==0.19.0, but you'll have scipy 1.0.0 which is incompatible.

In [4]:
import numpy.core.multiarray

In [5]:
!pip install spacy


Requirement already satisfied: spacy in c:\users\kogentix\anaconda3\lib\site-packages (2.0.11)
Requirement already satisfied: numpy>=1.7 in c:\users\kogentix\anaconda3\lib\site-packages (from spacy) (1.15.0)
Requirement already satisfied: murmurhash<0.29,>=0.28 in c:\users\kogentix\anaconda3\lib\site-packages (from spacy) (0.28.0)
Requirement already satisfied: cymem<1.32,>=1.30 in c:\users\kogentix\anaconda3\lib\site-packages (from spacy) (1.31.2)
Requirement already satisfied: preshed<2.0.0,>=1.0.0 in c:\users\kogentix\anaconda3\lib\site-packages (from spacy) (1.0.0)
Requirement already satisfied: thinc<6.11.0,>=6.10.1 in c:\users\kogentix\anaconda3\lib\site-packages (from spacy) (6.10.2)
Requirement already satisfied: plac<1.0.0,>=0.9.6 in c:\users\kogentix\anaconda3\lib\site-packages (from spacy) (0.9.6)
Requirement already satisfied: pathlib in c:\users\kogentix\anaconda3\lib\site-packages (from spacy) (1.0.1)
Requirement already satisfied: ujson>=1.35 in c:\users\kogentix\anaconda3\lib\site-packages (from spacy) (1.35)
Requirement already satisfied: dill<0.3,>=0.2 in c:\users\kogentix\anaconda3\lib\site-packages (from spacy) (0.2.7.1)
Requirement already satisfied: regex==2017.4.5 in c:\users\kogentix\anaconda3\lib\site-packages (from spacy) (2017.4.5)
Requirement already satisfied: wrapt in c:\users\kogentix\anaconda3\lib\site-packages (from thinc<6.11.0,>=6.10.1->spacy) (1.10.10)
Requirement already satisfied: tqdm<5.0.0,>=4.10.0 in c:\users\kogentix\anaconda3\lib\site-packages (from thinc<6.11.0,>=6.10.1->spacy) (4.23.0)
Requirement already satisfied: cytoolz<0.9,>=0.8 in c:\users\kogentix\anaconda3\lib\site-packages (from thinc<6.11.0,>=6.10.1->spacy) (0.8.2)
Requirement already satisfied: six<2.0.0,>=1.10.0 in c:\users\kogentix\anaconda3\lib\site-packages (from thinc<6.11.0,>=6.10.1->spacy) (1.11.0)
Requirement already satisfied: termcolor in c:\users\kogentix\anaconda3\lib\site-packages (from thinc<6.11.0,>=6.10.1->spacy) (1.1.0)
Requirement already satisfied: msgpack-python in c:\users\kogentix\anaconda3\lib\site-packages (from thinc<6.11.0,>=6.10.1->spacy) (0.4.8)
Requirement already satisfied: msgpack-numpy==0.4.1 in c:\users\kogentix\anaconda3\lib\site-packages (from thinc<6.11.0,>=6.10.1->spacy) (0.4.1)
Requirement already satisfied: pyreadline>=1.7.1 in c:\users\kogentix\anaconda3\lib\site-packages (from dill<0.3,>=0.2->spacy) (2.1)

In [7]:
! pip install scipy


Requirement already satisfied: scipy in c:\users\kogentix\anaconda3\lib\site-packages (1.0.0)

In [8]:
! pip install opencv-python


Requirement already satisfied: opencv-python in c:\users\kogentix\anaconda3\lib\site-packages (3.4.2.17)
Requirement already satisfied: numpy>=1.11.3 in c:\users\kogentix\anaconda3\lib\site-packages (from opencv-python) (1.15.0)

In [9]:
! pip install pillow


Requirement already satisfied: pillow in c:\users\kogentix\anaconda3\lib\site-packages (5.0.0)

In [10]:
! pip install matplotlib


Requirement already satisfied: matplotlib in c:\users\kogentix\anaconda3\lib\site-packages (2.2.2)
Requirement already satisfied: numpy>=1.7.1 in c:\users\kogentix\anaconda3\lib\site-packages (from matplotlib) (1.15.0)
Requirement already satisfied: cycler>=0.10 in c:\users\kogentix\anaconda3\lib\site-packages (from matplotlib) (0.10.0)
Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in c:\users\kogentix\anaconda3\lib\site-packages (from matplotlib) (2.1.4)
Requirement already satisfied: python-dateutil>=2.1 in c:\users\kogentix\anaconda3\lib\site-packages (from matplotlib) (2.6.1)
Requirement already satisfied: pytz in c:\users\kogentix\anaconda3\lib\site-packages (from matplotlib) (2017.2)
Requirement already satisfied: six>=1.10 in c:\users\kogentix\anaconda3\lib\site-packages (from matplotlib) (1.11.0)
Requirement already satisfied: kiwisolver>=1.0.1 in c:\users\kogentix\anaconda3\lib\site-packages (from matplotlib) (1.0.1)
Requirement already satisfied: setuptools in c:\users\kogentix\anaconda3\lib\site-packages (from kiwisolver>=1.0.1->matplotlib) (38.5.2)

In [11]:
! pip install h5py


Requirement already satisfied: h5py in c:\users\kogentix\anaconda3\lib\site-packages (2.7.1)
Requirement already satisfied: numpy>=1.7 in c:\users\kogentix\anaconda3\lib\site-packages (from h5py) (1.15.0)
Requirement already satisfied: six in c:\users\kogentix\anaconda3\lib\site-packages (from h5py) (1.11.0)

In [12]:
! pip install keras


Requirement already satisfied: keras in c:\users\kogentix\anaconda3\lib\site-packages (2.1.5)
Requirement already satisfied: pyyaml in c:\users\kogentix\anaconda3\lib\site-packages (from keras) (3.12)
Requirement already satisfied: scipy>=0.14 in c:\users\kogentix\anaconda3\lib\site-packages (from keras) (1.0.0)
Requirement already satisfied: six>=1.9.0 in c:\users\kogentix\anaconda3\lib\site-packages (from keras) (1.11.0)
Requirement already satisfied: numpy>=1.9.1 in c:\users\kogentix\anaconda3\lib\site-packages (from keras) (1.15.0)

In [13]:
! pip3 install https://github.com/OlafenwaMoses/ImageAI/releases/download/2.0.2/imageai-2.0.2-py3-none-any.whl


Requirement already satisfied: imageai==2.0.2 from https://github.com/OlafenwaMoses/ImageAI/releases/download/2.0.2/imageai-2.0.2-py3-none-any.whl in c:\users\kogentix\anaconda3\lib\site-packages (2.0.2)

Download the RetinaNet model file that will be used for object detection via this link https://github.com/OlafenwaMoses/ImageAI/releases/download/1.0/resnet50_coco_best_v2.0.1.h5


In [14]:
import os as os

In [15]:
os.getcwd()


Out[15]:
'C:\\Users\\KOGENTIX'

In [16]:
os.chdir('C:\\Users\\KOGENTIX\\Desktop\\image')

In [17]:
os.getcwd()


Out[17]:
'C:\\Users\\KOGENTIX\\Desktop\\image'

In [23]:
from imageai.Detection import ObjectDetection
import os

execution_path = os.getcwd()

detector = ObjectDetection()
detector.setModelTypeAsRetinaNet()
detector.setModelPath( os.path.join(execution_path , "resnet50_coco_best_v2.0.1.h5"))
detector.loadModel()
detections = detector.detectObjectsFromImage(input_image=os.path.join(execution_path , "image.jpeg"), output_image_path=os.path.join(execution_path , "imagenew.jpeg"))

for eachObject in detections:
    print(eachObject["name"] , " : " , eachObject["percentage_probability"] )


person  :  56.95698857307434
person  :  52.80917286872864
person  :  70.20386457443237
person  :  76.8346905708313
person  :  78.70020866394043
bicycle  :  79.7773540019989
person  :  83.55741500854492
person  :  89.43805694580078
truck  :  60.933083295822144
person  :  69.52632069587708
bus  :  98.00646901130676
truck  :  83.69445204734802
car  :  71.7008650302887

In [ ]: